import request from '@/utils/request'

// 查询商品管理列表
export function listGoods(query) {
  return request({
    url: '/admin/SGoods/goodsList',
    method: 'get',
    params: query
  })
}

// 查询商品管理列表(选择链接)
export function listChooseGoods(query) {
  return request({
    url: '/admin/SGoods/goodsChooseList',
    method: 'get',
    params: query
  })
}

// 查询商品管理详细
export function getGoods(goodsId) {
  return request({
    url: '/admin/SGoods/goodsDetails/goodsId/' + goodsId,
    method: 'get'
  })
}

// 新增商品管理
export function addGoods(data) {
  return request({
    url: '/admin/SGoods/goodsAdd',
    method: 'post',
    data: data
  })
}

// 修改商品管理
export function updateGoods(data) {
  return request({
    url: '/admin/SGoods/goodsEdit',
    method: 'put',
    data: data
  })
}

// 删除商品管理
export function delGoods(goodsId) {
  return request({
    url: '/admin/SGoods/goodsDel/goodsId/' + goodsId,
    method: 'delete'
  })
}

//上传商品轮播图
export function addFileGoodsImgs(data) {
  return request({
    url: '/admin/SGoods/addFileGoodsImgs',
    method: 'post',
    data: data,
    headers: {
      isFile: true
    },
  })
}

// 商品状态修改
export function changeGoodsStatus(goodsId, status) {
  const data = {
    goodsId,
    status
  }
  return request({
    url: '/admin/SGoods/changeStatus',
    method: 'put',
    data: data
  })
}
